<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const users = {
            Alex: {
                email: 'alex@alex.com',
                skills: ['HTML', 'CSS', 'JavaScript'],
                age: 20,
                isLoggedIn: false,  //是否
                points: 30
            },
            Asab: {
                email: 'asab@asab.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'],
                age: 25,
                isLoggedIn: false,
                points: 50
            },
            Brook: {
                email: 'daniel@daniel.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'],
                age: 30,
                isLoggedIn: true,
                points: 50
            },
            Daniel: {
                email: 'daniel@alex.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
                age: 20,
                isLoggedIn: false,
                points: 40
            },
            John: {
                email: 'john@john.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'],
                age: 20,
                isLoggedIn: true,
                points: 50
            },
            Thomas: {
                email: 'thomas@thomas.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React'],
                age: 20,
                isLoggedIn: false,
                points: 40
            },
            Paul: {
                email: 'paul@paul.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'],
                age: 20,
                isLoggedIn: false,
                points: 40
            }
        }
        const nameArr = Object.keys(users)  //keys:返回的是键的数组
        // console.log(nameArr);
        // 1.统计在线人数

        // count = 0
        // const arr = []
        // for(let i = 0;i<nameArr.length;i++){
        //     // console.log(nameArr[i]);
        //     // console.log(users[nameArr[i]].isLoggedIn);
        //     if(users[nameArr[i]].isLoggedIn){
        //         // arr.push(nameArr[i])
        //         count++
        //         console.log(nameArr[i]);
        //     }
        // }
        // console.log('在线人数'+count);

        count = 0
        nameArr.forEach(key => users[key].isLoggedIn ? count++ : count)   //遍历

        console.log('在线人数' + count);




        // console.log(arr);
        // 2.统计分数大于50的人数

        // 3.查找会MongoDB的人，并打印其名字
        const arr = []
        nameArr.forEach(key => users[key].skills.includes('MongoDB') ? arr.push(key) : arr)
        console.log('会MongoDB的人' + arr);
        // 4.查找同时会：MongoDB， Express，React，和Node 的人，并打印其名字
        const arr1 = []
        nameArr.forEach(key => users[key].skills.includes('React', 'JavaScript') ? arr1.push(key) : arr1)
        console.log('会MongoDB的人' + arr1);

    </script>
</body>

</html>